<!--
*@Author: QWP
*@Description: 资产领用申请
*@Date: 2024-07-08 09:51:28
-->
<template>
  <a-layout class="f-h-100 s-bg-white" id="test">
    <u-search-header>
      <u-form
        :model="searchF"
        :gutter="16"
        :elements="searchEl"
        class="f-w-auto">
        <u-search-button />
        <a-col flex="1">
          <a-row justify="end">
            <a-space>
              <u-icon-button itype="add" @click="showEdit = true">新增</u-icon-button>
              <u-icon-button itype="edit" @click="showEdit = true">修改</u-icon-button>
              <u-icon-button itype="delete" @click="">删除 </u-icon-button>
              <u-icon-button itype="report" @click="">送审 </u-icon-button>
            </a-space>
          </a-row>
        </a-col>
      </u-form>
    </u-search-header>
    <a-layout-content class="f-padding-rl24">
      <u-table
        :columns="columns"
        :data="tabData"
        v-model:pagination="pagenation"></u-table>
    </a-layout-content>
  </a-layout>

  <!-- 编辑弹窗 -->
  <Edit v-model:open="showEdit"
    wrap-class-name="full-modal"
    :title="dialogTitle" />
  
  <!-- 导入 -->
  <u-imp-data v-model:open="showImp"></u-imp-data>
</template>

<script lang="ts" setup>
import { ref, reactive, computed, onMounted, h, watch } from "vue";
import { useRoute, useRouter, onBeforeRouteUpdate, onBeforeRouteLeave} from "vue-router";
import { _IFormEl } from "@/components/common/form/interface";
import { ColProps, FormItemProps, TableColumnProps } from "ant-design-vue";
import { CheckCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { numberC } from '@/util/common'
import { formatAmt, } from '@/util/format.ts'
import dayjs from "dayjs";
import Edit from './Edit.vue'
import { cloneDeep } from 'lodash'
import { statusA } from '@/common/model/base'
const route = useRoute();
const router = useRouter();

onMounted(() => {
  initCols();
})

let pagenation = reactive({
  total: 0,
  current: 1,
  pageSize: 50,
  showTotal: total => `共 ${total} 条`
})
const searchF = reactive({
  model: {
    fwzh: "",
    fwzh1: "",
  },
});
const formItemProps: FormItemProps = {
  labelCol: { span: 8 },
  wrapperCol: { span: 16 },
};
const searchEl: Array<_IFormEl> = [
  { label: "数据状态", key: "status", element: "select", col: { span: 4 }, 
    formItemProps: formItemProps,
    componentProps: { options: statusA() }
  },
  { label: "关键字", key: "option", element: "input", col: { span: 4 }, formItemProps: formItemProps, },
];

// 列表
const tabData = reactive([
  { a: "是", b: "否", b1: '应急部门', b2: '马权', b3: '个人管理', b9: '其他',
    b4: dayjs().format("YYYY-MM-DD HH:MM:ss"), b5: '皮卡车', b6: '', b7: '待审核'
  },
  { a: "是", b: "否", b1: '应急部门', b2: '马权', b3: '部门管理', b9: '其他',
    b4: dayjs().format("YYYY-MM-DD HH:MM:ss"), b5: '帐篷', b6: '', b7: '已审核'
  },
]);
let columns: Array<TableColumnProps> = reactive([
  { dataIndex: "a", title: "是否发放", width: 100, align: 'center',  },
  { dataIndex: "b", title: "是否确认", width: 100, align: 'center',  },
  { dataIndex: "b1", title: "申请部门", minWidth: 150 },
  { dataIndex: "b2", title: "经办人", width: 100 },
  { dataIndex: "b3", title: "管理类型", width: 150 },
  { dataIndex: "b9", title: "来源", width: 150 },
  { dataIndex: "b4", title: "申请日期", width: 100, align: 'center',  },
  { dataIndex: "b5", title: "领用资产", width: 150 },
  { dataIndex: "b6", title: "备注", minWidth: 150 },
  { dataIndex: "b7", title: "数据状态", width: 100, fixed: 'right', align: 'center',  },
]);

// 初始化列表表头
const initCols = () => {
  return
  let tCols = cloneDeep(originCols)
  if(['DocDraft', 'DocRed'].includes(route.name)) {
    tCols = tCols.filter(item => item.dataIndex != 'status')
  }
  columns.splice(0, columns.length, ...tCols)
}

// 编辑
let dialogTitle = ref<string>("资产领用申请")
let showEdit = ref<boolean>(false)

// 导入
let showImp = ref<boolean>(false)

</script>

<style lang="scss" scoped>
.icons-list :deep(.anticon) {
  margin-right: 6px;
  font-size: 24px;
}
</style>
